import { listStation } from "@/api/service/station/station";
import { Station } from "@/api/service/station/types";
import { ENUM_DATA_SCOPE } from "@/enum/system.enum";
import { useQuery } from "@/hook/useTableConfig";

export const stationLoading = ref(true);
export const showStation = ref(false);

export const stationQuery = useQuery({
  scope: ENUM_DATA_SCOPE.THIS_AND_ALL_SUB,
  isAsc: "desc",
  orderByColumn: "station_id",
  filterId: ""
});

export const stationData = ref<Station[]>([]);
export const selectedKeys = ref<string[]>([]);
export const newStationColumns = [
  { title: "基站编码", dataIndex: "stationNum" },
  { title: "基站IP", dataIndex: "stationIp" },
  { title: "操作", dataIndex: "option" }
];

export const getStationList = async () => {
  stationLoading.value = true;
  try {
    const { rows, total } = await listStation(stationQuery.value);
    stationData.value = rows;
    stationQuery.value.total = total;
    stationLoading.value = false;
  } catch (error) {
    stationLoading.value = false;
  }
};
const resetQuery = () => {
  stationQuery.value.stationName = "";
};

const searchStation = () => {
  stationQuery.value.pageNum = 1;
  getStationList();
};
export { searchStation, resetQuery };
